﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>产品最新评论</title>
    <link rel="stylesheet" href="../../css/base.css">
    <link rel="stylesheet" href="../../css/font-style.css">
    <link rel="stylesheet" href="../../css/media.css">
    <link rel="stylesheet" href="../../css/AboutBrand.css">
    <link rel="stylesheet" href="../../css/ProductComment.css">
</head>
<body>
     <!-- 头部 -->
     <header>
        <span class="icon-arrow_lift back"></span>
        <a href="javascript:;" class="mmm">
            <img src="../../images/header_logo.png" alt="">
        </a>
        <!-- 头部中间文字，看需求 -->
        <!-- <span>头部</span> -->
        <a href="javascript:;">
            <img src="../../images/header_app.png" alt="">
        </a>
    </header>
    <!-- 产品 -->
    <h4 class="ProductSales_title">最细评论</h4>
    <div class="ProductSales_content ">
        <div class="content_left"><img src="" alt=""></div>
        <div class="content_right"></div>
    </div>    
    <!-- 评论 -->
    <div class="ProductComment">
        
    </div>
     <!-- 底部 -->
     <footer>
        <div class="foot_tool">
            <a href="javascript:;">登录</a>
            <a href="javascript:;">注册</a>
            <a href="javascript:;">返回顶部</a>
        </div>
        <div class="foot_content">
            <a href="javascript:;">手机APP下载
                <span>慢慢买手机版</span>
            </a>
            <span>--掌上比价平台</span>
            <p>m.manmanbuy.com</p>

        </div>
    </footer>
</body>
</html>
<script src="../../lib/zepto/zepto.min.js"></script>
<script src="../../lib/template/template.js"></script>

<!-- 评论模板 -->
<script type="text/template" id="navListTmp">
    {{each result as val key}}
        <div class="userCon">
                <span>{{val.comName}}</span>
                <span class="Comment_Form">{{val.comFrom}}</span>
                <p class="star">
                    <span class="icon-star"></span>
                    <span class="icon-star"></span>
                    <span class="icon-star"></span>
                    <span class="icon-star"></span>
                    <span class="icon-star"></span>
                </p>
                <span class="date">{{val.comTime}}</span>
        </div>
        <div class="Comment_Content">{{val.comContent}}</div>
   {{/each}}
</script>
<script type='text/javascript'>
    render();
    // 获取 销售页面中 缓存的图片路径 和 相关文本
    $('.content_left').children().attr('src',localStorage.getItem('img'));
    $('.content_right').text(localStorage.getItem('title'));
    function render(){
        //当前URL的?号开始的字符串 
        var param = window.location.search;
        //用正则匹配对应的id
        var id = param.match(/\d+/)[0];
        //分类ID
        // var brandTitleId = param.match(/brandTitleId=(.*)/)[1];
        $.ajax({
            type:'get',
            url:'http://193.112.55.79:9090/api/getproductcom',
            dataType:'json',
            data:{productid:id},
            success:function (res) {
                template.config("escape",false);//解析html中的图片
                
                // 准备模板字符串
                  var htmlStr = template('navListTmp',res);
                //   动态渲染数据
                  $('.ProductComment').html(htmlStr);
            }
        })
    }

    // 返回上一页
    $('.back').on('click',function(){
        window.history.go(-1);
    });
</script>
